[all:vars]
{% if ssh_port is defined %}
ansible_port={{ ssh_port }}
{% endif %}

{% if automation_hub|bool %}
[automation_hub]
{%   for host in hostvars %}
{%     if "automation-hub" in host %}
{{ host|replace(ec2_name_prefix + "-", "") }} ansible_host={{ hostvars[host].ansible_host }} ansible_port=22 ansible_user=ec2-user ansible_ssh_private_key_file="{{ playbook_dir }}/{{ ec2_name_prefix }}/{{ ec2_name_prefix }}-private.pem"
{%     endif %}
{%   endfor %}
{% endif %}

{% for number in range(1,student_total|int + 1) %}
[student{{ number }}]
{% for host in ansible_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-ansible ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }}
{% endif %}
{% endfor %}
{% for host in f5_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-f5 ansible_host={{ host.public_ip_address }} ansible_user=admin
{% endif %}
{% endfor %}
{% for host in node1_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-node1 ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }}
{% endif %}
{% endfor %}
{% for host in node2_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-node2 ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }}
{% endif %}
{% endfor %}
{% for host in f5_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-f5 ansible_host={{ host.public_ip_address }} ansible_user=admin
{% endif %}
{% endfor %}
{% for host in rtr1_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{ host.tags.short_name }} ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} ansible_network_os={{ host.tags.ansible_network_os }}
{% endif %}
{% endfor %}
{% for host in rtr2_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{ host.tags.short_name }} ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} ansible_network_os={{ host.tags.ansible_network_os }}
{% endif %}
{% endfor %}
{% for host in rtr3_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{ host.tags.short_name }} ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} ansible_network_os={{ host.tags.ansible_network_os }}
{% endif %}
{% endfor %}
{% for host in rtr4_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{ host.tags.short_name }} ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} ansible_network_os={{ host.tags.ansible_network_os }}
{% endif %}
{% endfor %}
{% if security_console == 'splunk' %}
{% for host in splunk_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-splunk ansible_host={{ host.public_ip_address }} ansible_user=admin
{% endif %}
{% endfor %}
{% endif %}
{% if security_console == 'qradar' %}
{% for host in qradar_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-qradar ansible_host={{ host.public_ip_address }} ansible_user=admin ansible_httpapi_pass="Ansible1!" ansible_connection=httpapi ansible_httpapi_use_ssl=yes ansible_httpapi_validate_certs=False ansible_network_os=ibm.qradar.qradar
{% endif %}
{% endfor %}
{% endif %}
{% for host in snort_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-snort ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} private_ip={{ hostvars[host.tags.Name]['private_ip'] }} private_ip2={{ hostvars[host.tags.Name]['private_ip2'] }}
{% endif %}
{% endfor %}
{% for host in attacker_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-attacker ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} private_ip={{ hostvars[host.tags.Name]['private_ip'] }} private_ip2={{ hostvars[host.tags.Name]['private_ip2'] }}
{% endif %}
{% endfor %}
{% for host in checkpoint_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-checkpoint ansible_host={{ host.public_ip_address }} ansible_user={{ host.tags.username }} ansible_password=admin123 ansible_network_os=checkpoint ansible_connection=httpapi ansible_httpapi_use_ssl=yes ansible_httpapi_validate_certs=no
{% endif %}
{% endfor %}
{% for host in windows_node_facts.instances %}
{% if 'student' ~ number == host.tags.Student %}
{{host.tags.Student}}-windows-ws ansible_host={{ host.public_ip_address }} ansible_user=Administrator ansible_password={{ windows_password }} ansible_port=5986 ansible_connection=winrm ansible_winrm_server_cert_validation=ignore
{% endif %}
{% endfor %}
{% for vm in instance1_node_facts.instances %}
{% if 'student' ~ number == vm.tags.Student %}
{{vm.tags.Student}}-{{ vm.tags.short_name }} ansible_host={{ vm.public_ip_address }} ansible_user=Administrator ansible_password="{{ hostvars[vm.tags.Student + '-win1'].ansible_password }}"
{% endif %}
{% endfor %}
{% if instance2_node_facts is defined %}
{% if instance2_node_facts.instances is defined %}
{% for vm in instance2_node_facts.instances %}
{% if 'student' ~ number == vm.tags.Student %}
{{vm.tags.Student}}-{{ vm.tags.short_name }} ansible_host={{ vm.public_ip_address }} ansible_user=Administrator ansible_password="{{ hostvars[vm.tags.Student + '-win2'].ansible_password }}"
{% endif %}
{% endfor %}
{% endif %}
{% endif %}


{% endfor %}
